package com.nmf.site.common.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class IdGenerater {
	@Autowired
	IdGen idGen;
	
	private String getTimeMils() {
		String times  = System.currentTimeMillis()+"";
		return times.substring(times.length()-4,times.length());
	}
	public String genInvNo() {
		return idGen.genRedisId("inv","IV")+getTimeMils();
	}
	public String genCarNo() {
		return idGen.genRedisId("car","CA")+getTimeMils();
	}
	
	public String genClsNo(String className) {
		String pre = "";
		if(StringUtils.isNotEmpty(className)) {
			pre = className.substring(0,2);
		}
		return idGen.genRedisId(className,pre.toUpperCase())+getTimeMils();
	}
	public String genNo(String pre) {
		return idGen.genRedisId("MCo",pre)+getTimeMils();
	}
	
}
